package com.expert.conrtoller;

import com.expert.annotations.RoleAnnotation;
import com.expert.dto.AddConditionDTO;
import com.expert.enums.RoleLevel;
import com.expert.result.Result;
import com.expert.service.ExtractConditionService;
import com.expert.vo.ExtractInitVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: ExtractController
 * @Author: cxs
 * @Date: 2024/03/21 21:09
 * @Description:
 **/
@RestController
@RequestMapping("/extract")
@Slf4j
public class ExtractConditionController {

    @Autowired
    ExtractConditionService extractConditionService;
    @RoleAnnotation(level = RoleLevel.ADMIN)
    @GetMapping("/getConditionInfo/{id}")
    public Result<ExtractInitVo> getConditionInfo(@PathVariable("id") Long id){
        ExtractInitVo extractInitVo=this.extractConditionService.getConditionInfo(id);
        return Result.success(extractInitVo);
    }

    /**
     *
     * @param addConditionDTO
     * @return
     */
    @PostMapping("/addCondition")
    public  Result addCondition(@RequestBody AddConditionDTO addConditionDTO){
        log.info("添加抽取条件");
        this.extractConditionService.addCondition(addConditionDTO);
        return Result.success();
    }
}
